package com.university.evaluation.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.university.evaluation.entity.AuditFlow;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 审核流程Mapper
 */
@Mapper
public interface AuditFlowMapper extends BaseMapper<AuditFlow> {

    /**
     * 根据记录ID查询审核流程
     */
    @Select("SELECT * FROM t_audit_flow WHERE record_id = #{recordId} ORDER BY audit_time ASC")
    List<AuditFlow> findByRecordId(@Param("recordId") String recordId);

    /**
     * 根据审核人ID查询审核记录
     */
    @Select("SELECT * FROM t_audit_flow WHERE auditor_id = #{auditorId} ORDER BY audit_time DESC")
    List<AuditFlow> findByAuditorId(@Param("auditorId") String auditorId);

    /**
     * 根据记录ID和审核人ID查询审核记录
     */
    @Select("SELECT * FROM t_audit_flow WHERE record_id = #{recordId} AND auditor_id = #{auditorId}")
    AuditFlow findByRecordIdAndAuditorId(@Param("recordId") String recordId, @Param("auditorId") String auditorId);
}
